package com.agileboot.domain.airport.danger.db;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class DangerSourceServiceImpl extends ServiceImpl<DangerSourceMapper, DangerSourceEntity>
        implements DangerSourceService {

    @Override
    public boolean isNameDuplicated(Long id, String name) {
        QueryWrapper<DangerSourceEntity> query = new QueryWrapper<>();
        query.eq("danger_source_name", name);
        if (id != null) {
            query.ne("danger_source_id", id);
        }
        return baseMapper.exists(query);
    }
}
